/*****************************************************************************************
 * Dexter : Distributed Experimental and Tester Platform
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *****************************************************************************************/
package dexter.net.msg;

import java.io.Serializable;

import dexter.core.host.HostAddress;
import dexter.util.IdGenerator;

public class BusMessage extends AbstractMessage {
	
    private static final long serialVersionUID = -167890372716819674L;
    private String id;

    private HostAddress fromAddress;
    private int numHops;
    private String context;
    private Serializable content;
    
    public BusMessage(HostAddress fromAddress) {
    	super(MessageType.BUS_MESSAGE);
    	this.fromAddress = fromAddress;
    	this.id = IdGenerator.generate();
    	//System.out.println("BusMessage ("+id+") creating ");
    }
    
    public BusMessage()  {
    	super(MessageType.BUS_MESSAGE);
    	this.id = IdGenerator.generate();
    	//System.out.println("BusMessage ("+id+") creating ");
    }

    public int getNumHops() {
    	//System.out.println("BusMessage ("+id+") getNumHops : "+numHops);
    	return numHops;
    }
    
    public void incNumHops() {
    	numHops++;
    	//System.out.println("BusMessage ("+id+") incNumHops : "+numHops);

    }
    
    public void setFromAddress(HostAddress ha) {
    	this.fromAddress = ha;
    }
    
    public HostAddress getFromAddress() {
    	return fromAddress;
    }
    
    public String getContext() {
		return context;
	}

	public void setContext(String context) {
		this.context = context;
	}

	public Serializable getContent() {
		return content;
	}

	public void setContent(Serializable content) {
		this.content = content;
	}

	public String toString() {
        return "RouteMessage (" + numHops + ')';
    }

}
